# 3.2 Sound Sensor ## 3.2.1 Overview The sound sensor, with excellent sound reception, mainly contains a high sensitivity microphone and an LM358 operational amplifier. Weak sound signals are captured by the microphone and amplified by LM358, so the output is clear and recognizable, which can be effectively detected the sounds. This sensor features high sensitivity, fast response speed, so is widely used in sound detection and recognition, providing a stable and reliable voice input solution for various intelligent devices. ## 3.2.2 Schematic Diagram ![6-4-2](./media/6-2-2.png) **Working principle:** If the built-in electret film vibrates after receiving sounds, its capacitance will change to produce a tiny voltage. The LM358 chip is adopted in circuits to amplify the sound signals detected by the high-sensitivity microphone. ## 3.2.3 Code Blocks 1. ![j12](./media/j12.png) This block sets baud rate, generally 9600 or 115200. In this project, the baud rate is 9600 by default. 2. ![j13](./media/j13.png) This block sets printing content on the monitor. There are three printing modes can be set: warp, no-warp, HEX(hexadecimal). **Warp** is the default mode. 3. ![j14](./media/j14.png) This module reads the analog value of the detected sound. ## 3.2.4 Test Code ## 3.2.4.1 Build Code There are two ways to upload the code: directly open the code file we provide; or manually build blocks. **Directly open the code file we provide:** 1. Click ![](./media/j68.png) and choose `Load from your computer` ![](./media/j67.png) 2. We have already downloaded the codes on computer desktop, so open the file and choose `3-2-sound.sb3` **Manually build blocks:** 1. In ![events](./media/events.png), find ![j1](./media/j1.png) block. 2. In ![serial](./media/serial.png), find ![j12](./media/j12.png) block and set baud rate to 9600, and put it under ![j1](./media/j1.png). 3. In ![control](./media/control.png), put ![j2](./media/j2.png) under ![6-4-4-1-1](./media/6-2-4-1-1.png). ![6-2](./media/6-2-4-1-2.png) 4. In ![serial](./media/serial.png), place ![j13](./media/j13.png) block into ![j2](./media/j2.png) 5. In ![sound](./media/sound.png), drag and put ![j14](./media/j14.png) into the content box of ![j13](./media/j13.png). **Complete Test Code** ![6-2](./media/6-2-4-1-3.png) ## 3.2.4.2 Test Result After uploading code, the analog value of the sound will be printed on the serial monitor. Note that click ![6-2](./media/6-2-4-1-4.png) to set the baud rate before uploading code. ![6-2](./media/6-2-4-1-5.png)